USE [PeDALS_DEV]
GO

/****** Object:  StoredProcedure [dbo].[PAC_CreateSeriesAcquisition]    Script Date: 10/14/2009 08:44:56 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


ALTER PROCEDURE [dbo].[PAC_CreateSeriesAcquisition]
	(@SeriesId INT,
	@SeriesAcquisitionReceivedDate DATETIME,
	@SeriesAcquisitionIngestDate DATETIME,
	@SeriesAcquisitionAccessionNumber VARCHAR (50),
	@SeriesAcquisitionTransferAuthority VARCHAR (50),
	@SeriesAcquisitionSource VARCHAR (100),	
	@SeriesAcquisitionDirectory VARCHAR (255),
    @SeriesAcquisitionGeneralNote VARCHAR (MAX),
	@AcqId INT OUTPUT)

AS
BEGIN
	TRY
	SET NOCOUNT ON
	BEGIN TRANSACTION
		INSERT INTO [PeDALS_DEV].[dbo].[SeriesAcquisition]
           ([SeriesId]
		   ,[SeriesAcquisitionReceivedDate]
           ,[SeriesAcquisitionIngestDate]
           ,[SeriesAcquisitionReadyToIngest]
		   ,[SeriesAcquisitionAccessionNumber]
           ,[SeriesAcquisitionTransferAuthority]
           ,[SeriesAcquisitionSource]
		   ,[SeriesAcquisitionDirectory]
           ,[SeriesAcquisitionGeneralNote]
           ,[CreatedDate]
           ,[CreatedBy])
     VALUES
           (@SeriesId
		   ,@SeriesAcquisitionReceivedDate
           ,@SeriesAcquisitionIngestDate
           ,'0'
		   ,@SeriesAcquisitionAccessionNumber
           ,@SeriesAcquisitionTransferAuthority
           ,@SeriesAcquisitionSource
		   ,@SeriesAcquisitionDirectory	
           ,@SeriesAcquisitionGeneralNote
           ,GETDATE()
           ,'Cataloger')
	SET @AcqId = SCOPE_IDENTITY()
	COMMIT TRANSACTION
END TRY
BEGIN CATCH
      ROLLBACK TRANSACTION
		PRINT 'An error occurred.  Please notify your administrator to check the error database.'
		INSERT INTO [PEDALS_PAC_ERRORS].[dbo].[PAC_ERROR](ErrorNumber, ErrorMessage, CreatedDate)
			VALUES (ERROR_NUMBER(), ERROR_MESSAGE(), GETDATE())
END CATCH

GO


